package com.example.JavaDemo.Controller;


import com.example.JavaDemo.domain.Community;
import com.example.JavaDemo.domain.Village;
import com.example.JavaDemo.service.IVillageService;
import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/villlage")
@Api(value = "village",tags = "小区管理")
public class VillageController {
    @Autowired
    private IVillageService villageSrrvice;

    @GetMapping("getVillageList")
    @ApiOperation("获取小区列表")
    public R<List<Village>> getVillageList(Village village){
        List<Village> list =villageSrrvice.selectVillage(village);
        return R.success(list);    }

    @PostMapping("addVillage")
    @ApiOperation("增加小区")
    public R<Village> addVillage(@RequestBody Village village){
        villageSrrvice.insertVillage(village);
        return R.success(village);
    }

    @PostMapping("updateVillageById")
    @ApiOperation("修改小区")
    public R<List<Community>> updateVillageById(@RequestBody Village village){
        villageSrrvice.updateVillageById(village);
        return R.success();
    }

    @DeleteMapping("delVillageById")
    @ApiOperation("删除小区")
    public R<List<Community>> delVillageById(String villageId){
        villageSrrvice.delVillageById(villageId);
        return R.success();
    }
}
